﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<UI.Areas.Admin.Models.UserModel>" %>
<%@ Import Namespace="UI.Helper" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Thay đổi mật khẩu
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%= Utils.IncludeJS(this.Html, "~/Scripts/jquery.validate.min.js")%>
    <!--  start page-heading -->
	<div id="page-heading">
		<h1>Thay Đổi Mật Khẩu Quản Trị</h1>
	</div>
	<!-- end page-heading -->

    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
		    <th rowspan="3" class="sized"><img src="<%= Utils.ResolveUrl(this.Html, "~/") %>images/admin/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
		    <th class="topleft"></th>
		    <td id="tbl-border-top">&nbsp;</td>
		    <th class="topright"></th>
		    <th rowspan="3" class="sized"><img src="<%= Utils.ResolveUrl(this.Html, "~/") %>images/admin/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
	    </tr>

        <tr>
            <td id="tbl-border-left"></td>
		    <td>
		    <!--  start content-table-inner ...................................................................... START -->
            <div id="content-table-inner">

                <table border="0" width="100%" cellpadding="0" cellspacing="0">
	            <tr valign="top">
	            <td>
                    <!--  start step-holder -->
		            <div id="step-holder">
			            <div class="step-no"></div>
			            <div class="step-dark-left"><a href="">Mật khẩu cũ và mới</a></div>
			            <div class="clear"></div>
		            </div>
		            <!--  end step-holder -->
                    
    			    <% Html.BeginForm("Index", "User", new { area = "Admin" }, FormMethod.Post, new { id = "infoForm" }); %>
    			        
                        <!-- start id-form -->
                        <table border="0" cellpadding="0" cellspacing="0" id="id-form">
                            <tr>
                                <th valign="top">
                                    
                                </th>
                                <td>
                                    <div id="errMessage" style="float: none; color: red; padding-left: .5em; vertical-align: top; font-weight:bold;">
                                        <%: ViewData[Constants.MESSAGE] ?? "" %>
                                    </div>
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <th valign="top">
                                    Mật khẩu cũ:
                                </th>
                                <td>
                                    <%: Html.PasswordFor(c => c.OldPassword, new { @class = "inp-form", id = "OldPassword" })%>
                                    <%: Html.HiddenFor(c => c.Id) %>
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <th valign="top">
                                    Mật khẩu mới:
                                </th>
                                <td>
                                    <%: Html.PasswordFor(c => c.NewPassword, new { @class = "inp-form", id = "NewPassword" })%>
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <th valign="top">
                                    Nhập lại mật khẩu mới:
                                </th>
                                <td>
                                    <%: Html.PasswordFor(c => c.NewPasswordConfirm, new { @class = "inp-form", id = "NewPasswordConfirm" })%>
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    &nbsp;
                                </th>
                                <td valign="top">
                                    <input type="submit" value="" class="form-submit" />
                                    <%--<input type="reset" value="" class="form-reset" />--%>
                                </td>
                                <td>
                                </td>
                            </tr>
                        </table>
                        <!-- end id-form  -->
    			    <% Html.EndForm(); %>
                </td>
                <td>
                    <!--  start related-activities -->
	                <div id="related-activities">&nbsp;</div>
	                <!-- end related-activities -->
                </td>
                </tr>
                </table>
			    
            </div>
            </td>
            <td id="tbl-border-right"></td>
        </tr>
        <tr>
		    <th class="sized bottomleft"></th>
		    <td id="tbl-border-bottom">&nbsp;</td>
		    <th class="sized bottomright"></th>
	    </tr>
    </table>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#infoForm").validate({
                rules:
                {
                    OldPassword: { required: true },
                    NewPassword: { required: true },
                    NewPasswordConfirm: { required: true }
                },
                messages:
                {
                    OldPassword: { required: 'Hãy nhập mật khẩu cũ.' },
                    NewPassword: { required: 'Hãy nhập mật khẩu mới.' },
                    NewPasswordConfirm: { required: 'Hãy nhập lại mật khẩu mới.' }
                },
                errorElement: "div",
                submitHandler: function (form) {
                    var newPass = $('#NewPassword').val();
                    var newPassCon = $('#NewPasswordConfirm').val();
                    
                    if (newPass != newPassCon)
                        $('#errMessage').html('Mật khẩu mới phải giống nhau');
                    else
                        $(form).submit();
                }
            })
        });
    </script>
</asp:Content>
